package com.ym.manager.admin.goods.model;

import com.ym.utils.Common;

public class Goods{
    /*主键id*/
    private int id;
    /*商户id*/
    private int merchant_id;
    /*商户名字*/
    private String merchant_name;
    /*商品名称*/
    private String name;
    /*商品单价（元）*/
    private int price;
    /*商品优惠价*/
    private int goods_discount_price;
    /*商品规格*/
    private String units;
    /*商品库存*/
    private int inventory;
    /*封面图*/
    private String cover_pic;
    /*轮播图*/
    private String banner;
    /*商品大类*/
    private int category_pid;
    /*商品二类*/
    private int category_id;
    /*分销价格*/
    private int price1;
    /*经理价格*/
    private int price2;
    /*总监*/
    private int price3;
    /*合伙人*/
    private int price4;
    /*是否差价商品 1是 2否*/
    private int is_discount;
    /*商品介绍*/
    private String desc_str;
    /*商品详情图片*/
    private String desc_pic;
    /*已售数量*/
    private int sold_quantity;
    /*保质期*/
    private int valid_time;
    /*商品类型 1 正常 2秒杀*/
    private int type;
    /*秒杀时间*/
    private int seckill_time;
    /*是否认证 0否 1是*/
    private int is_recommend;
    /*状态  1上架  2下架*/
    private int status;
    /*排序*/
    private long idx;
    /*最后更新时间*/
    private String update_time;
    /*创建时间*/
    private String create_time;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getMerchant_id() {
        return merchant_id;
    }

    public void setMerchant_id(int merchant_id) {
        this.merchant_id = merchant_id;
    }

    public String getMerchant_name() {
        return merchant_name;
    }

    public void setMerchant_name(String merchant_name) {
        this.merchant_name = merchant_name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public int getGoods_discount_price() {
        return goods_discount_price;
    }

    public void setGoods_discount_price(int goods_discount_price) {
        this.goods_discount_price = goods_discount_price;
    }

    public String getUnits() {
        return units;
    }

    public void setUnits(String units) {
        this.units = units;
    }

    public int getInventory() {
        return inventory;
    }

    public void setInventory(int inventory) {
        this.inventory = inventory;
    }

    public String getCover_pic() {
        return cover_pic;
    }

    public void setCover_pic(String cover_pic) {
        this.cover_pic = cover_pic;
    }

    public String getBanner() {
        return banner;
    }

    public void setBanner(String banner) {
        this.banner = banner;
    }

    public int getCategory_pid() {
        return category_pid;
    }

    public void setCategory_pid(int category_pid) {
        this.category_pid = category_pid;
    }

    public int getCategory_id() {
        return category_id;
    }

    public void setCategory_id(int category_id) {
        this.category_id = category_id;
    }

    public int getPrice1() {
        return price1;
    }

    public void setPrice1(int price1) {
        this.price1 = price1;
    }

    public int getPrice2() {
        return price2;
    }

    public void setPrice2(int price2) {
        this.price2 = price2;
    }

    public int getPrice3() {
        return price3;
    }

    public void setPrice3(int price3) {
        this.price3 = price3;
    }

    public int getPrice4() {
        return price4;
    }

    public void setPrice4(int price4) {
        this.price4 = price4;
    }

    public int getIs_discount() {
        return is_discount;
    }

    public void setIs_discount(int is_discount) {
        this.is_discount = is_discount;
    }

    public String getDesc_str() {
        return desc_str;
    }

    public void setDesc_str(String desc_str) {
        this.desc_str = desc_str;
    }

    public String getDesc_pic() {
        return desc_pic;
    }

    public void setDesc_pic(String desc_pic) {
        this.desc_pic = desc_pic;
    }

    public int getSold_quantity() {
        return sold_quantity;
    }

    public void setSold_quantity(int sold_quantity) {
        this.sold_quantity = sold_quantity;
    }

    public int getValid_time() {
        return valid_time;
    }

    public void setValid_time(int valid_time) {
        this.valid_time = valid_time;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getSeckill_time() {
        return seckill_time;
    }

    public void setSeckill_time(int seckill_time) {
        this.seckill_time = seckill_time;
    }

    public int getIs_recommend() {
        return is_recommend;
    }

    public void setIs_recommend(int is_recommend) {
        this.is_recommend = is_recommend;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public long getIdx() {
        return idx;
    }

    public void setIdx(long idx) {
        this.idx = idx;
    }

    public String getUpdate_time() {
        return update_time;
    }

    public void setUpdate_time(String update_time) {
        this.update_time = update_time;
    }

    public String getCreate_time() {
        return create_time;
    }

    public void setCreate_time(String create_time) {
        this.create_time = create_time;
    }

    public void picUrlChange(Goods goods){
        goods.setCover_pic(goods.getCover_pic().trim());
        //转换banner图
        String banner = goods.getBanner();
        StringBuilder bannerBuilder = new StringBuilder();
        if(Common.isNotEmpty(banner)){
            String[] bannerArray = banner.split(",");
            for(int i=0;i<bannerArray.length;i++){
                bannerBuilder.append(bannerArray[i].trim());
                if(i!=bannerArray.length-1){
                    bannerBuilder.append(",");
                }
            }
            goods.setBanner(bannerBuilder.toString());
        }

        //转换banner图
        String descPic = goods.getDesc_pic();
        StringBuilder descPicBuilder = new StringBuilder();
        if(Common.isNotEmpty(descPic)){
            String[] descPicArray = descPic.split(",");
            for(int i=0;i<descPicArray.length;i++){
                descPicBuilder.append(descPicArray[i]);
                if(i!=descPicArray.length-1){
                    descPicBuilder.append(",");
                }
            }
            goods.setDesc_pic(descPicBuilder.toString());
        }
    }

    public void picUrlDel(Goods goods,String picUrl){
        String cover_pic = goods.getCover_pic();
        if(Common.isNotEmpty(cover_pic)){
            goods.setCover_pic(cover_pic.trim().replaceAll(picUrl,""));
        }
        //转换banner图
        String banner = goods.getBanner();
        if(Common.isNotEmpty(banner)){
            goods.setBanner(banner.trim().replaceAll(picUrl,""));
        }

        //转换banner图
        String descPic = goods.getDesc_pic();
        if(Common.isNotEmpty(descPic)){
            goods.setDesc_pic(descPic.trim().replaceAll(picUrl,""));
        }
    }
}